<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>航班详情 - 航空订票系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="/flightbooking/">航空订票系统</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/">首页</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/flightbooking/flights">航班管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/passengers">旅客管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/tickets">票务管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/dashboard">统计面板</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="/flightbooking/">首页</a></li>
                <li class="breadcrumb-item"><a href="/flightbooking/flights">航班管理</a></li>
                <li class="breadcrumb-item active" aria-current="page">航班详情</li>
            </ol>
        </nav>

        <div class="card">
            <div class="card-header bg-primary text-white">
                <h5 class="mb-0">航班详情</h5>
            </div>
            <div class="card-body">
                <div class="row" th:if="${flight != null}">
                    <div class="col-md-6">
                        <table class="table table-bordered">
                            <tr>
                                <th width="150">航班号</th>
                                <td th:text="${flight.flightId}">CA1234</td>
                            </tr>
                            <tr>
                                <th>航空公司</th>
                                <td th:text="${flight.airlineCompany}">中国国际航空</td>
                            </tr>
                            <tr>
                                <th>出发城市</th>
                                <td th:text="${flight.departureCity}">北京</td>
                            </tr>
                            <tr>
                                <th>到达城市</th>
                                <td th:text="${flight.arrivalCity}">上海</td>
                            </tr>
                            <tr>
                                <th>出发时间</th>
                                <td th:text="${#dates.format(flight.departureTime, 'yyyy-MM-dd HH:mm')}">2023-07-01 08:00</td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-6">
                        <table class="table table-bordered">
                            <tr>
                                <th width="150">到达时间</th>
                                <td th:text="${#dates.format(flight.arrivalTime, 'yyyy-MM-dd HH:mm')}">2023-07-01 10:30</td>
                            </tr>
                            <tr>
                                <th>基本票价</th>
                                <td th:text="${flight.basePrice}">1200.00</td>
                            </tr>
                            <tr>
                                <th>座位容量</th>
                                <td th:text="${flight.capacity}">180</td>
                            </tr>
                            <tr>
                                <th>剩余座位</th>
                                <td th:text="${flight.remainingSeats}">150</td>
                            </tr>
                            <tr>
                                <th>状态</th>
                                <td>
                                    <span th:if="${flight.remainingSeats > 0}" class="badge badge-success">有座</span>
                                    <span th:if="${flight.remainingSeats <= 0}" class="badge badge-danger">满座</span>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                
                <div class="alert alert-danger" th:if="${flight == null}">
                    未找到航班信息
                </div>
                
                <div class="mt-3">
                    <a th:if="${flight != null && flight.remainingSeats > 0}" th:href="@{/tickets/book/{id}(id=${flight.flightId})}" class="btn btn-success">购买机票</a>
                    <a th:if="${flight != null}" th:href="@{/flights/edit/{id}(id=${flight.flightId})}" class="btn btn-warning">编辑航班</a>
                    <a th:if="${flight != null}" th:href="@{/flights/delete/{id}(id=${flight.flightId})}" class="btn btn-danger" onclick="return confirm('确定要删除此航班吗？')">删除航班</a>
                    <a href="/flightbooking/flights" class="btn btn-secondary">返回列表</a>
                </div>
            </div>
        </div>
    </div>

    <footer class="bg-dark text-light mt-5 py-3">
        <div class="container text-center">
            <p class="mb-0">© 2023 航空订票系统 - JZA04</p>
        </div>
    </footer>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 